import { ReactNode } from 'react';
import { Redirect } from 'umi'
import { useAuth } from '@/hooks'

interface Props {
    children?: ReactNode
}

export default (props: Props) => {
    // use开头是hooks
    // 自定义hook  
    const { isLogin } = useAuth();
    if (isLogin) {
        return <div>{props.children}</div>;
    } else {
        return <Redirect to="/login" />;
    }
}